
import postApi from '@/api/declaration/postApi'
import httpRequest from '@/config/axios/httpRequest'
import { QueryDeptDetailResp } from '@/models/base/DepartmentModel'
import {
  CreatePostReq,
  CreatePostResp,
  DeletePostReq,
  DeletePostResp,
  ExportPostReq,
  QueryPostDetailReq,
  QueryPostPageReq,
  QueryPostPageResp,
  UpdatePostReq,
  UpdatePostResp
} from '@/models/system/PostModel'

// 查询岗位列表
export const getPostPage = async (params: QueryPostPageReq) => {
  return await httpRequest.get<QueryPostPageResp>(postApi.QueryPostPage, { params })
}

// 查询岗位详情
export const getPost = async (params: QueryPostDetailReq) => {
  return await httpRequest.get<QueryDeptDetailResp>(postApi.QueryPostDetail, { params })
}

// 新增岗位
export const createPost = async (data: CreatePostReq) => {
  return await httpRequest.post<CreatePostResp>(postApi.CreatPost, data)
}

// 修改岗位
export const updatePost = async (data: UpdatePostReq) => {
  return await httpRequest.put<UpdatePostResp>(postApi.UpdatePost, data)
}

// 删除岗位
export const deletePost = async (params: DeletePostReq) => {
  return await httpRequest.delete<DeletePostResp>(postApi.DeletePost, { params })
}

// 导出岗位
export const exportPost = async (params: ExportPostReq) => {
  return await httpRequest.download(postApi.ExportPost, { params, responseType: 'blob' })
}
